﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class test_SendEmailAmazon : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        
            const String FROM = "support@nghikhac.com";   // Replace with your "From" address. This address must be verified.
            const String TO = "nguyen7huan@gmail.com";  // Replace with a "To" address. If you have not yet requested
                                                        // production access, this address must be verified.

            const String SUBJECT = "Đây là email thử nghiệm";
            const String BODY = "This email was sent through the Amazon SES SMTP interface by using C#.";

            // Supply your SMTP credentials below. Note that your SMTP credentials are different from your AWS credentials.
            const String SMTP_USERNAME = "AKIAJLAKZRHMUGKO353Q";  // Replace with your SMTP username. 
            const String SMTP_PASSWORD = "AtEnmsQ4ws/sBHLWJWtWlrrrx07UxJchbqbmJArCEl+R";  // Replace with your SMTP password.

            // Amazon SES SMTP host name. This example uses the us-east-1 region.
            const String HOST = "email-smtp.us-east-1.amazonaws.com";

            // Port we will connect to on the Amazon SES SMTP endpoint. We are choosing port 587 because we will use
            // STARTTLS to encrypt the connection.
            const int PORT = 587;

            clsEmail.sendMail(SMTP_USERNAME, SMTP_PASSWORD, "NghiKhac.Com", FROM, TO, SUBJECT, BODY, HOST);

            //// Create an SMTP client with the specified host name and port.
            //using (System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(HOST, PORT))
            //{
            //    // Create a network credential with your SMTP user name and password.
            //    client.Credentials = new System.Net.NetworkCredential(SMTP_USERNAME, SMTP_PASSWORD);

            //    // Use SSL when accessing Amazon SES. The SMTP session will begin on an unencrypted connection, and then 
            //    // the client will issue a STARTTLS command to upgrade to an encrypted connection using SSL.
            //    client.EnableSsl = true;

            //    // Send the email. 
            //    try
            //    {
            //        //Console.WriteLine("Attempting to send an email through the Amazon SES SMTP interface...");
            //        client.Send(FROM, TO, SUBJECT, BODY);
            //        //Console.WriteLine("Email sent!");
            //    }
            //    catch (Exception ex)
            //    {
            //        //Console.WriteLine("The email was not sent.");
            //        Console.WriteLine("Error message: " + ex.Message);
            //    }
            //}
    }
}